__author__ = 'Administrator'

'''
print("hello", "world", "!")
print("hello", "world", "!")
'''

'''
total = count = 0
while True:
    try:
        i = input("enter a num:")
        if i == "":
            break
        i = int(i)
        total += i
        count += 1
    except ValueError as e:
        print(e)
        continue

if count:
    print("count=", count, "total=", total, "mean=", total / count)
'''

SUFFIXES = {
    1000: ['KB', 'MB', 'GB', 'TB', 'PB'],
    1024: ['KiB', 'MiB', 'GiB', 'TiB', 'PiB']
}


def approximate_size(size, a_kilobyte_is_1024_bytes=True):
    if int(size) < 0:
        raise ValueError('number must be non-negative')

    multiple = 1024 if a_kilobyte_is_1024_bytes else 1000;
    for suffix in SUFFIXES[multiple]:
        size /= multiple
        if size < multiple:
            return '{0:.1f} {1}'.format(size, suffix)

    raise ValueError('number too large')


print(approximate_size(1024))
print(approximate_size(10001024))
print(approximate_size(10001024, False))
print(approximate_size(0, False))
# print(approximate_size(-9, False))__author__ = 'Administrator'
